from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from time import sleep

driver = webdriver.Chrome()
# js加载视频
# driver.get("https://videojs.com/")
# sleep(2)
# video = WebDriverWait(driver, 5, 0.5).until(EC.presence_of_element_located((By.TAG_NAME, 'video')))
# url = driver.execute_script("return arguments[0].currentSrc;", video)
# print("url:", url)
# # 播放
# driver.execute_script("arguments[0].play();", video)
# sleep(5)
# # 暂停
# driver.execute_script("arguments[0].pause();", video)
# sleep(5)


# driver.get("https://www.bilibili.com/video/BV1Kg411B7X4/")
# sleep(2)
# # video = WebDriverWait(driver, 10, 0.5).until(EC.presence_of_element_located((By.ID, '__video')))
# video = driver.find_element_by_tag_name("video")
# url = driver.execute_script("return arguments[0].currentSrc;", video)
# print("url:", url)
# # 播放
# # driver.execute_script("return arguments[0].play();", video)
# # sleep(5)
# # 暂停
# driver.execute_script("arguments[0].pause();", video)
# sleep(5)

# (取消)置灰
driver.get("https://www.baidu.com/")
disabled = "document.getElementById('kw').disabled='true'"
driver.execute_script(disabled)
# driver.find_element_by_id("kw").send_keys("123")    # 不可用
# 隐藏搜索框
hide = "document.getElementById('kw').style.display='none'"
driver.execute_script(hide)
driver.refresh()

sleep(2)
driver.quit()

